# -*- coding: utf-8 -*-
'''
| @author: stone.li
| Created on: 2022/11/21 12:01
| desc: 产业大屏100市+所有省code
'''


import pandas as pd
import os


# 获取100市+所有省份/100市的code
def get_region_codes(region):
    if region == "city":
        file = "city_region_codes.csv"
    else:
        file = 'all_region_codes.csv'
    # path_list = os.path.dirname(os.path.realpath(__file__)).split(os.sep)
    # path = ''
    # for i in range(path_list.index("automation_framework")+1):
    #     path = path+path_list[i]+os.sep
    # path = path + "data" + os.sep + "IDS" + os.sep + file
    res = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
    path = res + os.sep + "data" + os.sep + "IDS" + os.sep + file
    with open(path, encoding="UTF-8") as file:
        data = pd.read_csv(file)
        region_codes = data.values.tolist()
    return region_codes


# 调试用
def get_test_region_codes():
    file = "test_region_codes.csv"
    res = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
    path = res + os.sep + "data" + os.sep + "IDS" + os.sep + file
    with open(path, encoding="UTF-8") as file:
        data = pd.read_csv(file)
        region_codes = data.values.tolist()
    return region_codes
